#include <stdio.h>

int maxProfit(int* prices, int pricesSize)
{
    int max = prices[1] - prices[0];
    for(int i = 0;i < pricesSize;i++)
    {
        for(int j = i + 1;j < pricesSize;j++)
        {
            if(max < (prices[j] - prices[i]))
            {
                max = prices[j] - prices[i];
            }
        }
    }
    return max;
}

int main()
{
    int prices[] = {3,2,8,4,1,6};
    int pricesSize = sizeof(prices)/sizeof(prices[0]);
    printf("%d\n",maxProfit(prices, pricesSize));
    return 0;
}